//package com.lottery.service.pc28.lobbyService.impl;
//
//import com.lottery.dao.pc28.lobbyDao.BettinginfoDao;
//import com.lottery.dao.pc28.lobbyDao.LotteryOddsDao;
//import com.lottery.dto.ResultDto;
//import com.lottery.entity.Bettinginfo;
//import com.lottery.entity.LotteryExchange;
//import com.lottery.obtainData.SscYesWinningFactory.SscYesWinningImpl;
//import com.lottery.service.pc28.JedisClient;
//import com.lottery.service.pc28.lobbyService.LotteryDrawService;
//import com.lottery.service.pc28.lobbyService.LotteryExchangeService;
//import com.lottery.service.pc28.statisticsService.AgencyMoneyService;
//import com.lottery.service.pc28.statisticsService.PlaywayMoneyService;
//import com.lottery.service.pc28.statisticsService.TotalMoneyService;
//import com.lottery.service.pc28.statisticsService.UserTop10Service;
//import com.lottery.utils.RobotParams;
//import com.lottery.utils.TouristData;
//import com.lottery.utils.playUtils.SscPlayUtilNum;
//import com.lottery.utils.playUtils.SscPlayUtilsNoNum;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Service;
//
//import javax.annotation.PostConstruct;
//import java.util.*;
//import java.util.Map.Entry;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//
//@Service
//public class LotteryDrawServiceImpl implements LotteryDrawService {
//	@Autowired
//	private SscFactory sscFactory;
//
//	@Autowired
//	private LotteryOddsDao lotteryOddsDao;
//
//	@Autowired
//	private BettinginfoDao bettinginfoDao;
//
//	@Autowired
//	private LotteryExchangeService lotteryExchangeService;
//
//	@Autowired
//	private UserTop10Service userTop10Service;
//
//	@Autowired
//	private AgencyMoneyService agencyMoneyService;
//
//	@Autowired
//	private PlaywayMoneyService playwayMoneyService;
//
//	@Autowired
//	private TotalMoneyService totalMoneyService;
//
//	@Autowired
//	private JedisClient jedisClient;
//
//
//	private Map<String, String> betMap;
//
//	private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
//	// 中奖信息标志key
//	@Value("${PC28FLG}")
//	private String PC28FLG;
//	@Value("${SSCFLG}")
//	private String SSCFLG;
//	// 开始下注
//	@Value("${BEGAINBET}")
//	private String BEGAINBET;
//	// 开始下注
//	@Value("${OPENNUM}")
//	private String OPENNUM;
//	// 开奖信息前缀
//	@Value("${BEFOR}")
//	private String BEFOR;
//	// 开奖信息后缀
//	@Value("${AFTER}")
//	private String AFTER;
//
//	public static boolean bl = true;
//
//	@PostConstruct
//	public void init() {
//		betMap = new HashMap<String, String>();
//		betMap.put("单点00", "00");
//		betMap.put("单点01", "01");
//		betMap.put("单点02", "02");
//		betMap.put("单点03", "03");
//		betMap.put("单点04", "04");
//		betMap.put("单点05", "05");
//		betMap.put("单点06", "06");
//		betMap.put("单点07", "07");
//		betMap.put("单点08", "08");
//		betMap.put("单点09", "09");
//		betMap.put("单点10", "10");
//		betMap.put("单点11", "11");
//		betMap.put("单点12", "12");
//		betMap.put("单点13", "13");
//		betMap.put("单点14", "14");
//		betMap.put("单点15", "15");
//		betMap.put("单点16", "16");
//		betMap.put("单点17", "17");
//		betMap.put("单点18", "18");
//		betMap.put("单点19", "19");
//		betMap.put("单点20", "20");
//		betMap.put("单点21", "21");
//		betMap.put("单点22", "22");
//		betMap.put("单点23", "23");
//		betMap.put("单点24", "24");
//		betMap.put("单点25", "25");
//		betMap.put("单点26", "26");
//		betMap.put("单点27", "27");
//	}
//
//	/**
//	 * 分割汉字和数字
//	 *
//	 * @param args
//	 */
//	private static String Division(String s) {
//
//		Pattern p = Pattern.compile("[\\u4e00-\\u9fa5]+|\\d+");
//		Matcher m = p.matcher(s);
//		String group = "";
//		if (m.find()) {
//			group = m.group();
//		}
//		return group;
//	}
//
//	/**
//	 * 统计字符串中包含字符的个数
//	 *
//	 * @param str
//	 * @param s
//	 * @return
//	 */
//	private static int Count(String[] str, String s) {
//
//		int count = 0;
//		for (int index = 0; index < str.length; index++) {
//
//			if (str[index].equals(s)) {
//
//				count++;
//			}
//		}
//
//		return count;
//	}
//
//	/**
//	 * 判断数字组合玩法
//	 *
//	 * @param opencode
//	 * @param s
//	 * @return
//	 */
//	private static boolean Include(String opencode, String s) {
//		boolean flg = false;
//		for (int index = 0; index < s.length(); index++) {
//			if (opencode.indexOf(s.charAt(index)) != -1) {
//				flg = true;
//			} else {
//				return false;
//			}
//		}
//
//		return flg;
//	}
//
//	private static int IncludeNums(String opencode, String s) {
//		// boolean flg = false;
//		int num = 0;
//		String tmpStr = opencode;
//		int length = 0;
//		for (int index = 0; index < s.length(); index++) {
//			length = tmpStr.length();
//			tmpStr = tmpStr.replaceAll(s.substring(index, index + 1), "");
//			int changeLength = length - tmpStr.length();
//			if (changeLength > 0) {
//				num += changeLength;
//			} else {
//				return 0;
//			}
//		}
//
//		return num;
//	}
//
//	/**
//	 * 中奖规则
//	 */
//	public ResultDto<LotteryExchange> pc28YesWinning(String opencode, String expect, int lotteyType) {
//
//		// 开奖完成状态
//		bl = false;
//
//		jedisClient.del(PC28FLG);
//
//		ResultDto<LotteryExchange> result = new ResultDto<LotteryExchange>();
//
//		if (null == opencode || "".equals(opencode.trim())) {
//			bl = true;
//			result.setSuccess(false);
//			result.setMessage("开奖结果不能为空！");
//			logger.error("opencode is null");
//			return result;
//		}
//
//		// 分割字符串
//		String[] str = opencode.split(",");
//
//		if (str.length != 3) {
//			bl = true;
//			result.setSuccess(false);
//			result.setMessage("开奖结果格式不正确！");
//			logger.error("opencode format error");
//			return result;
//		}
//		// 三个数字总和
//		int amount = Integer.parseInt(str[0]) + Integer.parseInt(str[1]) + Integer.parseInt(str[2]);
//
//		// 是否是豹子
//		boolean duizi = false;
//		boolean shunzi = false;
//		boolean baozi = ((str[0].equals(str[1])) && (str[0].equals(str[2])) ? true : false);
//
//		// 是否是对子
//		if (!baozi) {
//			Set<String> set = new HashSet<>();
//
//			for (String string : str) {
//				try {
//					set.add(string);
//				} catch (Exception e) {
//				}
//			}
//
//			if (set.size() == 2) {
//				duizi = true;
//			}
//
//			// 是否是顺子
//			if (!duizi) {
//				int[] arrays = { Integer.parseInt(str[0]), Integer.parseInt(str[1]), Integer.parseInt(str[2]) };
//				Arrays.sort(arrays);
//				if (((arrays[1] - arrays[0]) == 1) && ((arrays[2] - arrays[1]) == 1)) {
//					shunzi = true;
//				}
//			}
//		}
//
//		int pageNow = 1;
//		while (true) {
//			// int startCount = (pageNow - 1) * 50;
//			List<Bettinginfo> bettinginfoList = bettinginfoDao.selectBettinginfoPage(expect, lotteyType);
//
//			logger.info("pc28 查询下注记录的数据 dataTag={}", bettinginfoList);
//
//			// 判断下注表是否有数据
//			if (null == bettinginfoList || bettinginfoList.size() == 0) {
//				bl = true;
//				break;
//			}
//
//			// 遍历
//			for (Bettinginfo bettinginfo : bettinginfoList) {
//				// 玩法名称
//				String playwayName = bettinginfo.getPlaywayName();
//				// 下注规则
//				String bettingrule = bettinginfo.getBettingrule();
//
//				boolean sign = true;
//
//				try {
//					// 下注的内容 大100 小100 大单100 小单100 大双100 小双100
//					if ("大小单双玩法".equals(playwayName)) {
//
//						// 分割数字和汉字
//						/* String betting = Division(bettingrule); */
//						String betting = bettingrule;
//						logger.debug("bet rule:{}--{}--{}", playwayName, betting, amount);
//
//						if ("大".equals(betting) && amount >= 14) {
//
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							} else {
//								String betWay = "大";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							}
//							sign = false;
//						} else if ("小".equals(betting) && amount <= 13) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							} else {
//								String betWay = "小";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							}
//							sign = false;
//						} else if ("单".equals(betting) && amount % 2 != 0) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							} else {
//								String betWay = "单";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							}
//							sign = false;
//						} else if ("双".equals(betting) && amount % 2 == 0) {
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							} else {
//								String betWay = "双";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							}
//							sign = false;
//						} else if ("大单".equals(betting) && amount >= 14 && amount % 2 != 0) {
//							String betWay = "大单";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("小单".equals(betting) && amount <= 13 && amount % 2 != 0) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							} else {
//								String betWay = "小单";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							}
//							sign = false;
//						} else if ("大双".equals(betting) && amount >= 14 && amount % 2 == 0) {
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							} else {
//								String betWay = "大双";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							}
//							sign = false;
//						} else if ("小双".equals(betting) && amount <= 13 && amount % 2 == 0) {
//							String betWay = "小双";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						}
//
//					}
//
//					// 猜数字玩法
//					else if ("猜数字玩法".equals(playwayName)) {
//						/* String betting = Division(bettingrule); */
//						String betting = bettingrule;
//						if (duizi && "对子".equals(betting)) {
//							String betWay = "对子";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if (baozi && "豹子".equals(betting)) {
//							String betWay = "豹子";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if (shunzi && "顺子".equals(betting)) {
//							String betWay = "顺子";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if (amount <= 5 && "极小".equals(betting)) {
//							String betWay = "极小";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if (amount >= 22 && "极大".equals(betting)) {
//							String betWay = "极大";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						}
//					}
//
//					// 单点玩法
//					else if ("单点".equals(playwayName)) {
//						/*
//						 * String three = ""; String threePlay = ""; String
//						 * threeAfter = ""; if (bettingrule.length() >= 7) {
//						 * three = bettingrule.substring(0, 2); threePlay =
//						 * bettingrule.substring(2, 4); threeAfter =
//						 * bettingrule.substring(5); }
//						 *
//						 * int iThreePlay = Integer.parseInt(threePlay);
//						 */
//						if (amount == Integer.parseInt(bettingrule.substring(2))) {
//							String betWay = betMap.get(bettingrule);
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						}
//
//					}
//
//					// 修改中奖状态,未中奖
//					if (sign) {
//						bettinginfo.setState(0);
//						bettinginfoDao.updateBettinginfo(bettinginfo);
//					}
//
//				} catch (Exception e) {
//					e.printStackTrace();
//					logger.error("pc28kaijiang error:", e);
//				}
//				pageNow++;
//			}
//		}
//
//		// pc28游客开奖
//		for (Entry<Integer, ArrayList<Bettinginfo>> entity : TouristData.touristPc28Betting.entrySet()) {
//			ArrayList<Bettinginfo> bets = entity.getValue();
//			try {
//				ArrayList<LotteryExchange> lotteryExchangelist = new ArrayList<LotteryExchange>();
//				for (Bettinginfo bettinginfo : bets) {
//					// 获取玩法名称
//					String playwayName = bettinginfo.getPlaywayName();
//					// 获取下注规则
//					String bettingrule = bettinginfo.getBettingrule();
//					boolean sign = true;
//					// 中奖判断
//					if ("大小单双玩法".equals(playwayName)) {
//
//						// 分割数字和汉字
//						/* String betting = Division(bettingrule); */
//						String betting = bettingrule;
//						logger.debug("bet rule:{}--{}--{}", playwayName, betting, amount);
//
//						if ("大".equals(betting) && amount >= 14) {
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "大";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("小".equals(betting) && amount <= 13) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "小";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("单".equals(betting) && amount % 2 != 0) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "单";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("双".equals(betting) && amount % 2 == 0) {
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "双";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("大单".equals(betting) && amount >= 14 && amount % 2 != 0) {
//							String betWay = "大单";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小单".equals(betting) && amount <= 13 && amount % 2 != 0) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "小单";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("大双".equals(betting) && amount >= 14 && amount % 2 == 0) {
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "大双";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("小双".equals(betting) && amount <= 13 && amount % 2 == 0) {
//							String betWay = "小双";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//
//					}
//
//					// 猜数字玩法
//					else if ("猜数字玩法".equals(playwayName)) {
//						/* String betting = Division(bettingrule); */
//						String betting = bettingrule;
//						if (duizi && "对子".equals(betting)) {
//							String betWay = "对子";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (baozi && "豹子".equals(betting)) {
//							String betWay = "豹子";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (shunzi && "顺子".equals(betting)) {
//							String betWay = "顺子";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (amount <= 5 && "极小".equals(betting)) {
//							String betWay = "极小";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (amount >= 22 && "极大".equals(betting)) {
//							String betWay = "极大";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//
//					// 单点玩法
//					else if ("单点".equals(playwayName)) {
//						/*
//						 * String three = ""; String threePlay = ""; String
//						 * threeAfter = ""; if (bettingrule.length() >= 7) {
//						 * three = bettingrule.substring(0, 2); threePlay =
//						 * bettingrule.substring(2, 4); threeAfter =
//						 * bettingrule.substring(5); }
//						 *
//						 * int iThreePlay = Integer.parseInt(threePlay);
//						 */
//						if (amount == Integer.parseInt(bettingrule.substring(2))) {
//							String betWay = betMap.get(bettingrule);
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//
//					}
//					// 修改中奖状态,未中奖
//					if (sign) {
//						LotteryExchange lotteryExchange = new LotteryExchange();
//						lotteryExchange.setUserId(bettinginfo.getUserId());
//						lotteryExchange.setBettinginfoId(bettinginfo.getBettingnumber());
//						lotteryExchange.setBettingrule(bettinginfo.getBettingrule());
//						lotteryExchange.setPlaywayName(bettinginfo.getPlaywayName());
//						lotteryExchange.setLotteryType(lotteyType);
//						lotteryExchange.setExpect(bettinginfo.getExpect());
//						lotteryExchange.setWinningamount(0);
//						lotteryExchangelist.add(lotteryExchange);
//					}
//				}
//				TouristData.touristPc28Win.put(entity.getKey(), lotteryExchangelist);
//				TouristData.touristPc28Betting.get(entity.getKey()).clear();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//		}
//
//		// 遍历机器人开奖
//		logger.debug("****pc28robot start winbet  in  ***************");
//		RobotParams.robotPc28Win.clear();
//		for (Entry<Integer, ArrayList<Bettinginfo>> entry : RobotParams.robotPc28Betting.entrySet()) {
//			ArrayList<Bettinginfo> bets = entry.getValue();
//			try {
//				ArrayList<LotteryExchange> lotteryExchangelist = new ArrayList<LotteryExchange>();
//				for (Bettinginfo bettinginfo : bets) {
//					// 玩法名称
//					String playwayName = bettinginfo.getPlaywayName();
//					// 下注规则
//					String bettingrule = bettinginfo.getBettingrule();
//
//					logger.debug("****robot pc28kaijiang:{}{}", bettingrule, bettinginfo.getBettingmoney());
//
//					boolean sign = true;
//
//					// 下注的内容 大100 小100 大单100 小单100 大双100 小双100
//					if ("大小单双玩法".equals(playwayName)) {
//
//						// 分割数字和汉字
//						String betting = Division(bettingrule);
//						logger.debug("bet rule:{}--{}--{}", playwayName, betting, amount);
//
//						if ("大".equals(betting) && amount >= 14) {
//
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "大";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("小".equals(betting) && amount <= 13) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "小";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("单".equals(betting) && amount % 2 != 0) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "单";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("双".equals(betting) && amount % 2 == 0) {
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "双";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("大单".equals(betting) && amount >= 14 && amount % 2 != 0) {
//							String betWay = "大单";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小单".equals(betting) && amount <= 13 && amount % 2 != 0) {
//							if (amount == 13) {
//								String betWay = "小13";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "小单";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("大双".equals(betting) && amount >= 14 && amount % 2 == 0) {
//							if (amount == 14) {
//								String betWay = "大14";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							} else {
//								String betWay = "大双";
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							}
//							sign = false;
//						} else if ("小双".equals(betting) && amount <= 13 && amount % 2 == 0) {
//							String betWay = "小双";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//
//					}
//
//					// 猜数字玩法
//					else if ("猜数字玩法".equals(playwayName)) {
//						String betting = Division(bettingrule);
//						if (duizi && "对子".equals(betting)) {
//							String betWay = "对子";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (baozi && "豹子".equals(betting)) {
//							String betWay = "豹子";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (shunzi && "顺子".equals(betting)) {
//							String betWay = "顺子";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (amount <= 5 && "极小".equals(betting)) {
//							String betWay = "极小";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if (amount >= 22 && "极大".equals(betting)) {
//							String betWay = "极大";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//
//					// 单点玩法
//					else if ("单点".equals(playwayName)) {
//						String three = "";
//						String threePlay = "";
//						String threeAfter = "";
//						if (bettingrule.length() >= 7) {
//							three = bettingrule.substring(0, 2);
//							threePlay = bettingrule.substring(2, 4);
//							threeAfter = bettingrule.substring(5);
//						}
//
//						int iThreePlay = Integer.parseInt(threePlay);
//						if (amount == iThreePlay) {
//							String betWay = betMap.get(amount);
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//
//					// 修改中奖状态,未中奖
//					if (sign) {
//						LotteryExchange lotteryExchange = new LotteryExchange();
//						lotteryExchange.setUserId(bettinginfo.getUserId());
//						lotteryExchange.setBettinginfoId(bettinginfo.getId());
//						lotteryExchange.setBettingrule(bettinginfo.getBettingrule());
//						lotteryExchange.setPlaywayName(bettinginfo.getPlaywayName());
//						lotteryExchange.setExpect(bettinginfo.getExpect());
//						lotteryExchange.setWinningamount(0);
//						lotteryExchangelist.add(lotteryExchange);
//					}
//				}
//				RobotParams.robotPc28Win.put(entry.getKey(), lotteryExchangelist);
//				RobotParams.robotPc28Betting.get(entry.getKey()).clear();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//		}
//
//		// 用户比例分成
//		try {
//			lotteryExchangeService.UserRateSharing(expect, lotteyType);
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		logger.info("用户比例分成 yonghufc={}", "用户比例分成完成");
//
//		// 将开奖数据存入redis
//		// winningResultsService.selectWinningResultsService(expect);
//		// logger.info("将开奖数据存入rediswc={}", "将开奖数据存入redis完成");
//
//		// 开奖完成的状态
//		bl = true;
//		// betNoticeService.insertPromptNotice(BEGAINBET);
//
//		// 统计userTop10
//		userTop10Service.insetUserTop10(expect, lotteyType);
//		// 每期代理商分类统计金额
//		agencyMoneyService.insetAgencyMoney(expect);
//		// 每期玩法分类统计金额
//		playwayMoneyService.insetPlaywayMoney(expect);
//		// 统计每期总金额
//		totalMoneyService.insetTotalMoney(expect);
//
//		result.setSuccess(true);
//		result.setMessage("开奖成功！");
//
//		return result;
//
//	}
//
//	/**
//	 * ssc开奖规则
//	 *
//	 * @param opencode
//	 * @param expect
//	 * @param lotteyType
//	 * @return
//	 */
//	@Override
//	public ResultDto<LotteryExchange> sscYesWinning(String opencode, String expect, int lotteyType) {
//		// 中奖状态
//		bl = false;
//
//		jedisClient.del(SSCFLG);
//
//		ResultDto<LotteryExchange> result = new ResultDto<LotteryExchange>();
//
//		if (null == opencode || "".equals(opencode.trim())) {
//			bl = true;
//			result.setSuccess(false);
//			result.setMessage("开奖结果不能为空！");
//			return result;
//		}
//
//		// 分割字符串
//		String[] str = opencode.split(",");
//
//		if (str.length != 5) {
//			bl = true;
//			result.setSuccess(false);
//			result.setMessage("开奖结果格式不正确！");
//			return result;
//		}
//		// 五个数字总和
//		int amount = Integer.parseInt(str[0]) + Integer.parseInt(str[1]) + Integer.parseInt(str[2])
//				+ Integer.parseInt(str[3]) + Integer.parseInt(str[4]);
//
//		/*
//		 * String rule = ""; if(amount >= 23 && amount % 2 != 0){ rule="大单";
//		 * }else if(amount < 23 && amount % 2 != 0){ rule="小单"; }else if(amount
//		 * >= 23 && amount % 2 == 0){ rule="大双"; }else if(amount < 23 && amount
//		 * % 2 == 0){ rule="小双"; } //开奖号码
//		 * betNoticeService.insertPromptNotice(BEFOR+expect+OPENNUM+opencode.
//		 * replace( ",", " ")+" "+rule+AFTER);
//		 */
//
//		int pageNow = 1;
//		while (true) {
//			// int startCount = (pageNow - 1) * 50;
//			List<Bettinginfo> bettinginfoList = bettinginfoDao.selectBettinginfoPage(expect, lotteyType);
//			logger.info("ssc 查询下注记录的数据  dataTag={}", bettinginfoList);
//
//			// 判断下注表是否有数据
//			if (null == bettinginfoList || bettinginfoList.size() == 0) {
//				bl = true;
//				break;
//			}
//
//			// 遍历
//			for (Bettinginfo bettinginfo : bettinginfoList) {
//				// 玩法名称
//				String playwayName = bettinginfo.getPlaywayName();
//				// 下注规则
//				String bettingrule = bettinginfo.getBettingrule();
//
//				boolean sign = true;
//				try {
//					// 新解决方案
//					// SscYesWinningImpl sscYesWinning = new
//					// SscFactory().getSscYesWinning(bettingrule,sign,bettinginfo,lotteyType,amount,opencode,playwayName);
//					// sign=sscYesWinning.winning();
//
//					if ("大小单双玩法".equals(playwayName)) {
//
//						// 分割数字和汉字
//						String betting = bettingrule;
//
//						if ("大".equals(betting) && amount >= 23) {
//							String betWay = "大";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("小".equals(betting) && amount < 23) {
//							String betWay = "小";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("单".equals(betting) && amount % 2 != 0) {
//							String betWay = "单";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("双".equals(betting) && amount % 2 == 0) {
//							String betWay = "双";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("大单".equals(betting) && amount >= 23 && amount % 2 != 0) {
//							String betWay = "大单";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("小单".equals(betting) && amount < 23 && amount % 2 != 0) {
//							String betWay = "小单";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("大双".equals(betting) && amount >= 23 && amount % 2 == 0) {
//							String betWay = "大双";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						} else if ("小双".equals(betting) && amount < 23 && amount % 2 == 0) {
//							String betWay = "小双";
//							lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//							sign = false;
//						}
//
//					} else {
//						// 猜合 合100
//						if ("猜合".equals(playwayName)) {
//							// 分割数字和汉字
//							String betting = bettingrule;
//
//							if ("合".equals(betting) && str[0].equals(str[4])) {
//								String betWay = "合";
//								lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//								sign = false;
//							}
//						} else {
//
//							// 根据"/"分割
//							// String[] splitBet = bettingrule.split("/");
//							String betNumber = bettingrule.substring(2);
//							// 数字玩法 1
//							int length = betNumber.length();
//
//							if ("数字玩法".equals(playwayName)) {
//
//								if (length == 1 && opencode.contains(betNumber)) {
//									// 统计出现下中的数字个数
//									int count = Count(str, betNumber);
//									String betWay = String.valueOf(count);
//									lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//									sign = false;
//								}
//							}
//							// 数字组合玩法 12 123 1234 12345
//							else if ("数字组合玩法".equals(playwayName)) {
//								if (length > 1) {
//									int num = IncludeNums(opencode, betNumber);
//									if (num > 1) {
//										String betWay = "00" + num;
//										lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//										sign = false;
//									}
//								}
//
//							}
//							// 数字定位玩法 1/2
//							else if ("数字定位玩法".equals(playwayName)) {
//								String[] splitBet = betNumber.split("/");
//								// 转化为int
//								int parseInt = Integer.parseInt(splitBet[0]);
//
//								if (str[parseInt - 1].equals(splitBet[1])) {
//									String betWay = "定位";
//									lotteryExchangeService.insertLotteryExchange(bettinginfo, betWay, lotteyType);
//									sign = false;
//								}
//
//							}
//						}
//
//					}
//
//					// 修改中奖状态,未中奖
//					if (sign) {
//						bettinginfo.setState(0);
//						bettinginfoDao.updateBettinginfo(bettinginfo);
//					}
//				} catch (Exception e) {
//					e.printStackTrace();
//					logger.error("ssckaijiang error:", e);
//				}
//
//			}
//			pageNow++;
//		}
//
//		// 游客开奖
//		for (Entry<Integer, ArrayList<Bettinginfo>> entity : TouristData.touristBetting.entrySet()) {
//			ArrayList<Bettinginfo> bets = entity.getValue();
//			try {
//				ArrayList<LotteryExchange> lotteryExchangelist = new ArrayList<LotteryExchange>();
//				for (Bettinginfo bettinginfo : bets) {
//					// 玩法名称
//					String playwayName = bettinginfo.getPlaywayName();
//					// 下注规则
//					String bettingrule = bettinginfo.getBettingrule();
//
//					boolean sign = true;
//
//					// 下注的内容 大100 小100 大单100 小单100 大双100 小双100
//					if ("大小单双玩法".equals(playwayName)) {
//
//						// 分割数字和汉字
//						String betting = bettingrule;
//
//						if ("大".equals(betting) && amount >= 23) {
//							String betWay = "大";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小".equals(betting) && amount < 23) {
//							String betWay = "小";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("单".equals(betting) && amount % 2 != 0) {
//							String betWay = "单";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("双".equals(betting) && amount % 2 == 0) {
//							String betWay = "双";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("大单".equals(betting) && amount >= 23 && amount % 2 != 0) {
//							String betWay = "大单";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小单".equals(betting) && amount < 23 && amount % 2 != 0) {
//							String betWay = "小单";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("大双".equals(betting) && amount >= 23 && amount % 2 == 0) {
//							String betWay = "大双";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小双".equals(betting) && amount < 23 && amount % 2 == 0) {
//							String betWay = "小双";
//							lotteryExchangelist.add(
//									lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//
//					} else {
//						// 猜合 合
//						if ("猜合".equals(playwayName)) {
//							// 分割数字和汉字
//							String betting = bettingrule;
//
//							if ("合".equals(betting) && str[0].equals(str[4])) {
//								String betWay = "合";
//								lotteryExchangelist.add(
//										lotteryExchangeService.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//								sign = false;
//							}
//						} else {
//							// 根据"/"分割
//							// String[] splitBet = bettingrule.split("/");
//							String betNumber = bettingrule.substring(2);
//							// 数字玩法 1
//							int length = betNumber.length();
//							if ("数字玩法".equals(playwayName)) {
//
//								if (length == 1 && opencode.contains(betNumber)) {
//									// 统计出现下中的数字个数
//									int count = Count(str, betNumber);
//									String betWay = String.valueOf(count);
//									lotteryExchangelist.add(lotteryExchangeService.touristLotteryExchange(bettinginfo,
//											betWay, lotteyType));
//									sign = false;
//								}
//							}
//							// 数字组合玩法 12/100 123/100 1234/100 12345/100
//							else if ("数字组合玩法".equals(playwayName)) {
//								if (length > 1) {
//									int num = IncludeNums(opencode, betNumber);
//									if (num > 1) {
//										String betWay = "00" + num;
//										lotteryExchangelist.add(lotteryExchangeService
//												.touristLotteryExchange(bettinginfo, betWay, lotteyType));
//										sign = false;
//									}
//								}
//
//							}
//							// 数字定位玩法 1/2/100
//							else if ("数字定位玩法".equals(playwayName)) {
//								String[] splitBet = betNumber.split("/");
//								// 转化为int
//								int parseInt = Integer.parseInt(splitBet[0]);
//
//								if (str[parseInt - 1].equals(splitBet[1])) {
//									String betWay = "定位";
//									lotteryExchangelist.add(lotteryExchangeService.touristLotteryExchange(bettinginfo,
//											betWay, lotteyType));
//									sign = false;
//								}
//							}
//						}
//
//					}
//
//					// 修改中奖状态,未中奖
//					if (sign) {
//						LotteryExchange lotteryExchange = new LotteryExchange();
//						lotteryExchange.setUserId(bettinginfo.getUserId());
//						lotteryExchange.setBettinginfoId(bettinginfo.getBettingnumber());
//						lotteryExchange.setBettingrule(bettinginfo.getBettingrule());
//						lotteryExchange.setPlaywayName(bettinginfo.getPlaywayName());
//						lotteryExchange.setExpect(bettinginfo.getExpect());
//						lotteryExchange.setWinningamount(0);
//						lotteryExchangelist.add(lotteryExchange);
//					}
//				}
//				TouristData.touristWin.put(entity.getKey(), lotteryExchangelist);
//				TouristData.touristBetting.get(entity.getKey()).clear();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//		}
//
//		// 遍历机器人开奖
//		logger.debug("****sscrobot start winbet  in  ***************");
//		// if (RobotUserService.robotOnlineUser.size() != 0) {
//		for (Entry<Integer, ArrayList<Bettinginfo>> entry : RobotParams.robotSscBetting.entrySet()) {
//			ArrayList<Bettinginfo> bets = entry.getValue();
//			try {
//
//				ArrayList<LotteryExchange> lotteryExchangelist = new ArrayList<LotteryExchange>();
//				for (Bettinginfo bettinginfo : bets) {
//					// 玩法名称
//					String playwayName = bettinginfo.getPlaywayName();
//					// 下注规则
//					String bettingrule = bettinginfo.getBettingrule();
//					logger.debug("****robot ssckaijiang:{}{}", bettingrule, bettinginfo.getBettingmoney());
//					boolean sign = true;
//
//					// 下注的内容 大100 小100 大单100 小单100 大双100 小双100
//					if ("大小单双玩法".equals(playwayName)) {
//
//						// 分割数字和汉字
//						String betting = Division(bettingrule);
//
//						if ("大".equals(betting) && amount >= 23) {
//							String betWay = "大";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小".equals(betting) && amount < 23) {
//							String betWay = "小";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("单".equals(betting) && amount % 2 != 0) {
//							String betWay = "单";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("双".equals(betting) && amount % 2 == 0) {
//							String betWay = "双";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("大单".equals(betting) && amount >= 23 && amount % 2 != 0) {
//							String betWay = "大单";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小单".equals(betting) && amount < 23 && amount % 2 != 0) {
//							String betWay = "小单";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("大双".equals(betting) && amount >= 23 && amount % 2 == 0) {
//							String betWay = "大双";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小双".equals(betting) && amount < 23 && amount % 2 == 0) {
//							String betWay = "小双";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//
//					}
//					// 猜合 合100
//					if ("猜合".equals(playwayName)) {
//						// 分割数字和汉字
//						String betting = Division(bettingrule);
//
//						if ("合".equals(betting) && str[0].equals(str[4])) {
//							String betWay = "合";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//
//					// 根据"/"分割
//					String[] splitBet = bettingrule.split("/");
//
//					// 数字玩法 1/100
//					int length = splitBet[0].length();
//					if ("数字玩法".equals(playwayName)) {
//
//						if (splitBet.length == 2 && length == 1 && opencode.contains(splitBet[0])) {
//							// 统计出现下中的数字个数
//							int count = Count(str, splitBet[0]);
//							String betWay = String.valueOf(count);
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//					// 数字组合玩法 12/100 123/100 1234/100 12345/100
//					if ("数字组合玩法".equals(playwayName)) {
//						if (splitBet.length == 2 && length > 1) {
//							int num = IncludeNums(opencode, splitBet[0]);
//							if (num > 1) {
//								String betWay = "00" + num;
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//								sign = false;
//							}
//						}
//
//					}
//					// 数字定位玩法 1/2/100
//					if ("数字定位玩法".equals(playwayName)) {
//						// 转化为int
//						int parseInt = Integer.parseInt(splitBet[0]);
//
//						if (splitBet.length == 3 && str[parseInt - 1].equals(splitBet[1])) {
//							String betWay = "定位";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//					// 修改中奖状态,未中奖
//					if (sign) {
//						LotteryExchange lotteryExchange = new LotteryExchange();
//						lotteryExchange.setUserId(bettinginfo.getUserId());
//						lotteryExchange.setBettinginfoId(bettinginfo.getId());
//						lotteryExchange.setBettingrule(bettinginfo.getBettingrule());
//						lotteryExchange.setPlaywayName(bettinginfo.getPlaywayName());
//						lotteryExchange.setExpect(bettinginfo.getExpect());
//						lotteryExchange.setWinningamount(0);
//						lotteryExchangelist.add(lotteryExchange);
//					}
//				}
//				RobotParams.robotSscWin.put(entry.getKey(), lotteryExchangelist);
//				RobotParams.robotSscBetting.get(entry.getKey()).clear();
//			} catch (Exception e) {
//				logger.error("robot kaijiang error", e);
//				e.printStackTrace();
//			}
//		}
//
//		// 用户比例分成
//		try {
//			lotteryExchangeService.UserRateSharing(expect, lotteyType);
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		logger.info("用户比例分成 yonghufc={}", "用户比例分成完成");
//
//		// 将开奖数据存入redis
//		// winningResultsService.selectWinningResultsService(expect);
//		// logger.info("将开奖数据存入rediswc={}", "将开奖数据存入redis完成");
//
//		// 开奖完成的状态
//		bl = true;
//		// betNoticeService.insertPromptNotice(BEGAINBET);
//
//		// 统计userTop10
//		userTop10Service.insetUserTop10(expect, lotteyType);
//		// 每期代理商分类统计金额
//		agencyMoneyService.insetAgencyMoney(expect);
//		// 每期玩法分类统计金额
//		playwayMoneyService.insetPlaywayMoney(expect);
//		// 统计每期总金额
//		totalMoneyService.insetTotalMoney(expect);
//
//		result.setSuccess(true);
//		result.setMessage("开奖成功！");
//
//		return result;
//	}
//
//	/**
//	 * ssc新改规则
//	 *
//	 * @param opencode
//	 * @param expect
//	 * @param lotteyType
//	 * @return
//	 */
//	@Override
//	public ResultDto<LotteryExchange> sscYesWinning2(String opencode, String expect, int lotteyType) {
//		// 中奖状态
//		bl = false;
//
//		jedisClient.del(SSCFLG);
//
//		ResultDto<LotteryExchange> result = new ResultDto<LotteryExchange>();
//
//		if (null == opencode || "".equals(opencode.trim())) {
//			bl = true;
//			result.setSuccess(false);
//			result.setMessage("开奖结果不能为空！");
//			return result;
//		}
//
//		// 分割字符串
//		String[] str = opencode.split(",");
//
//		if (str.length != 5) {
//			bl = true;
//			result.setSuccess(false);
//			result.setMessage("开奖结果格式不正确！");
//			return result;
//		}
//		// 五个数字总和
//		int amount = Integer.parseInt(str[0]) + Integer.parseInt(str[1]) + Integer.parseInt(str[2])
//				+ Integer.parseInt(str[3]) + Integer.parseInt(str[4]);
//
//		/*
//		 * String rule = ""; if(amount >= 23 && amount % 2 != 0){ rule="大单";
//		 * }else if(amount < 23 && amount % 2 != 0){ rule="小单"; }else if(amount
//		 * >= 23 && amount % 2 == 0){ rule="大双"; }else if(amount < 23 && amount
//		 * % 2 == 0){ rule="小双"; } //开奖号码
//		 * betNoticeService.insertPromptNotice(BEFOR+expect+OPENNUM+opencode.
//		 * replace( ",", " ")+" "+rule+AFTER);
//		 */
//
//		int pageNow = 1;
//		// 下注来源(0:代表注册用户,1:代表游客)
//		int betResource = 0;
//
//		//得到开奖结果
//		SscPlayUtilNum sscPlayUtilNum = new SscPlayUtilNum(opencode);
//		SscPlayUtilsNoNum sscPlayUtilsNoNum = new SscPlayUtilsNoNum(opencode);
//
//		while (true) {
//			// int startCount = (pageNow - 1) * 50;
//			List<Bettinginfo> bettinginfoList = bettinginfoDao.selectBettinginfoPage(expect, lotteyType);
//			logger.info("ssc 查询下注记录的数据  dataTag={}", bettinginfoList);
//
//			// 判断下注表是否有数据
//			if (null == bettinginfoList || bettinginfoList.size() == 0) {
//				bl = true;
//				break;
//			}
//
//			// 正常用户遍历
//			for (Bettinginfo bettinginfo : bettinginfoList) {
//				// 将游客开奖和正常开奖合并产生的累赘,待优化
//				// ArrayList<LotteryExchange> lotteryExchangelist = new
//				// ArrayList<LotteryExchange>();
//				// 玩法名称
//				String playwayName = bettinginfo.getPlaywayName();
//				// 下注规则
//				String bettingrule = bettinginfo.getBettingrule();
//
//				// boolean sign = true;
//				try {
//					logger.debug("normal win::,{}",bettinginfo.getBettingrule());
//					//SscYesWinningImpl sscYesWinning = sscFactory.getSscYesWinning(playwayName);
//					//boolean sign = sscYesWinning.winning(bettinginfo, lotteyType, amount, opencode, betResource, null,sscPlayUtilsNoNum,sscPlayUtilNum);
//					if (sign) {
//						bettinginfo.setState(0);
//						bettinginfoDao.updateBettinginfo(bettinginfo);
//					}
//				} catch (Exception e) {
//					e.printStackTrace();
//					logger.error("ssckaijiang error:", e);
//				}
//
//			}
//			pageNow++;
//		}
//
//		// 游客开奖
//		for (Entry<Integer, ArrayList<Bettinginfo>> entity : TouristData.touristBetting.entrySet()) {
//			// 将下注来源改为游客
//			betResource = 1;
//			ArrayList<Bettinginfo> bets = entity.getValue();
//			try {
//				ArrayList<LotteryExchange> lotteryExchangelist = new ArrayList<LotteryExchange>();
//				for (Bettinginfo bettinginfo : bets) {
//					// 玩法名称
//					String playwayName = bettinginfo.getPlaywayName();
//					// 下注规则
//					String bettingrule = bettinginfo.getBettingrule();
//
//					SscYesWinningImpl sscYesWinning = new SscFactory().getSscYesWinning(playwayName);
//					boolean sign = sscYesWinning.winning(bettinginfo, lotteyType, amount, opencode, betResource,
//							lotteryExchangelist,sscPlayUtilsNoNum,sscPlayUtilNum);
//
//					// // 下注的内容 大100 小100 大单100 小单100 大双100 小双100
//					// if ("大小单双玩法".equals(playwayName)) {
//					//
//					// // 分割数字和汉字
//					// String betting = bettingrule;
//					//
//					// if ("大".equals(betting) && amount >= 23) {
//					// String betWay = "大";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// } else if ("小".equals(betting) && amount < 23) {
//					// String betWay = "小";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// } else if ("单".equals(betting) && amount % 2 != 0) {
//					// String betWay = "单";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// } else if ("双".equals(betting) && amount % 2 == 0) {
//					// String betWay = "双";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// } else if ("大单".equals(betting) && amount >= 23 && amount
//					// % 2 != 0) {
//					// String betWay = "大单";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// } else if ("小单".equals(betting) && amount < 23 && amount
//					// % 2 != 0) {
//					// String betWay = "小单";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// } else if ("大双".equals(betting) && amount >= 23 && amount
//					// % 2 == 0) {
//					// String betWay = "大双";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// } else if ("小双".equals(betting) && amount < 23 && amount
//					// % 2 == 0) {
//					// String betWay = "小双";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// }
//					//
//					// } else {
//					// // 猜合 合
//					// if ("猜合".equals(playwayName)) {
//					// // 分割数字和汉字
//					// String betting = bettingrule;
//					//
//					// if ("合".equals(betting) && str[0].equals(str[4])) {
//					// String betWay = "合";
//					// lotteryExchangelist.add(
//					// lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay,
//					// lotteyType));
//					// sign = false;
//					// }
//					// } else {
//					// // 根据"/"分割
//					// // String[] splitBet = bettingrule.split("/");
//					// String betNumber = bettingrule.substring(2);
//					// // 数字玩法 1
//					// int length = betNumber.length();
//					// if ("数字玩法".equals(playwayName)) {
//					//
//					// if (length == 1 && opencode.contains(betNumber)) {
//					// // 统计出现下中的数字个数
//					// int count = Count(str, betNumber);
//					// String betWay = String.valueOf(count);
//					// lotteryExchangelist.add(lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay, lotteyType));
//					// sign = false;
//					// }
//					// }
//					// // 数字组合玩法 12/100 123/100 1234/100 12345/100
//					// else if ("数字组合玩法".equals(playwayName)) {
//					// if (length > 1) {
//					// int num = IncludeNums(opencode, betNumber);
//					// if (num > 1) {
//					// String betWay = "00" + num;
//					// lotteryExchangelist.add(lotteryExchangeService
//					// .touristLotteryExchange(bettinginfo, betWay,
//					// lotteyType));
//					// sign = false;
//					// }
//					// }
//					//
//					// }
//					// // 数字定位玩法 1/2/100
//					// else if ("数字定位玩法".equals(playwayName)) {
//					// String[] splitBet = betNumber.split("/");
//					// // 转化为int
//					// int parseInt = Integer.parseInt(splitBet[0]);
//					//
//					// if (str[parseInt - 1].equals(splitBet[1])) {
//					// String betWay = "定位";
//					// lotteryExchangelist.add(lotteryExchangeService.touristLotteryExchange(bettinginfo,
//					// betWay, lotteyType));
//					// sign = false;
//					// }
//					// }
//					// }
//					//
//					// }
//
//					// 修改中奖状态,未中奖
//					if (sign) {
//						LotteryExchange lotteryExchange = new LotteryExchange();
//						lotteryExchange.setUserId(bettinginfo.getUserId());
//						lotteryExchange.setBettinginfoId(bettinginfo.getBettingnumber());
//						lotteryExchange.setBettingrule(bettinginfo.getBettingrule());
//						lotteryExchange.setPlaywayName(bettinginfo.getPlaywayName());
//						lotteryExchange.setExpect(bettinginfo.getExpect());
//						lotteryExchange.setWinningamount(0);
//						lotteryExchangelist.add(lotteryExchange);
//					}
//				}
//				TouristData.touristWin.put(entity.getKey(), lotteryExchangelist);
//				TouristData.touristBetting.get(entity.getKey()).clear();
//			} catch (Exception e) {
//				e.printStackTrace();
//			}
//		}
//
//		// 遍历机器人开奖
//		logger.debug("****sscrobot start winbet  in  ***************");
//		// if (RobotUserService.robotOnlineUser.size() != 0) {
//		for (Entry<Integer, ArrayList<Bettinginfo>> entry : RobotParams.robotSscBetting.entrySet()) {
//			ArrayList<Bettinginfo> bets = entry.getValue();
//			try {
//
//				ArrayList<LotteryExchange> lotteryExchangelist = new ArrayList<LotteryExchange>();
//				for (Bettinginfo bettinginfo : bets) {
//					// 玩法名称
//					String playwayName = bettinginfo.getPlaywayName();
//					// 下注规则
//					String bettingrule = bettinginfo.getBettingrule();
//					logger.debug("****robot ssckaijiang:{}{}", bettingrule, bettinginfo.getBettingmoney());
//					boolean sign = true;
//
//					// 下注的内容 大100 小100 大单100 小单100 大双100 小双100
//					if ("大小单双玩法".equals(playwayName)) {
//
//						// 分割数字和汉字
//						String betting = Division(bettingrule);
//
//						if ("大".equals(betting) && amount >= 23) {
//							String betWay = "大";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小".equals(betting) && amount < 23) {
//							String betWay = "小";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("单".equals(betting) && amount % 2 != 0) {
//							String betWay = "单";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("双".equals(betting) && amount % 2 == 0) {
//							String betWay = "双";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("大单".equals(betting) && amount >= 23 && amount % 2 != 0) {
//							String betWay = "大单";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小单".equals(betting) && amount < 23 && amount % 2 != 0) {
//							String betWay = "小单";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("大双".equals(betting) && amount >= 23 && amount % 2 == 0) {
//							String betWay = "大双";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						} else if ("小双".equals(betting) && amount < 23 && amount % 2 == 0) {
//							String betWay = "小双";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//
//					}
//					// 猜合 合100
//					if ("猜合".equals(playwayName)) {
//						// 分割数字和汉字
//						String betting = Division(bettingrule);
//
//						if ("合".equals(betting) && str[0].equals(str[4])) {
//							String betWay = "合";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//
//					// 根据"/"分割
//					String[] splitBet = bettingrule.split("/");
//
//					// 数字玩法 1/100
//					int length = splitBet[0].length();
//					if ("数字玩法".equals(playwayName)) {
//
//						if (splitBet.length == 2 && length == 1 && opencode.contains(splitBet[0])) {
//							// 统计出现下中的数字个数
//							int count = Count(str, splitBet[0]);
//							String betWay = String.valueOf(count);
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//					// 数字组合玩法 12/100 123/100 1234/100 12345/100
//					if ("数字组合玩法".equals(playwayName)) {
//						if (splitBet.length == 2 && length > 1) {
//							int num = IncludeNums(opencode, splitBet[0]);
//							if (num > 1) {
//								String betWay = "00" + num;
//								lotteryExchangelist.add(
//										lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//								sign = false;
//							}
//						}
//
//					}
//					// 数字定位玩法 1/2/100
//					if ("数字定位玩法".equals(playwayName)) {
//						// 转化为int
//						int parseInt = Integer.parseInt(splitBet[0]);
//
//						if (splitBet.length == 3 && str[parseInt - 1].equals(splitBet[1])) {
//							String betWay = "定位";
//							lotteryExchangelist
//									.add(lotteryExchangeService.robotLotteryExchange(bettinginfo, betWay, lotteyType));
//							sign = false;
//						}
//					}
//					// 修改中奖状态,未中奖
//					if (sign) {
//						LotteryExchange lotteryExchange = new LotteryExchange();
//						lotteryExchange.setUserId(bettinginfo.getUserId());
//						lotteryExchange.setBettinginfoId(bettinginfo.getId());
//						lotteryExchange.setBettingrule(bettinginfo.getBettingrule());
//						lotteryExchange.setPlaywayName(bettinginfo.getPlaywayName());
//						lotteryExchange.setExpect(bettinginfo.getExpect());
//						lotteryExchange.setWinningamount(0);
//						lotteryExchangelist.add(lotteryExchange);
//					}
//				}
//				RobotParams.robotSscWin.put(entry.getKey(), lotteryExchangelist);
//				RobotParams.robotSscBetting.get(entry.getKey()).clear();
//			} catch (Exception e) {
//				logger.error("robot kaijiang error", e);
//				e.printStackTrace();
//			}
//		}
//
//		// 用户比例分成
//		try {
//			lotteryExchangeService.UserRateSharing(expect, lotteyType);
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		logger.info("用户比例分成 yonghufc={}", "用户比例分成完成");
//
//		// 将开奖数据存入redis
//		// winningResultsService.selectWinningResultsService(expect);
//		// logger.info("将开奖数据存入rediswc={}", "将开奖数据存入redis完成");
//
//		// 开奖完成的状态
//		bl = true;
//		// betNoticeService.insertPromptNotice(BEGAINBET);
//
//		// 统计userTop10
//		userTop10Service.insetUserTop10(expect, lotteyType);
//		// 每期代理商分类统计金额
//		agencyMoneyService.insetAgencyMoney(expect);
//		// 每期玩法分类统计金额
//		playwayMoneyService.insetPlaywayMoney(expect);
//		// 统计每期总金额
//		totalMoneyService.insetTotalMoney(expect);
//
//		result.setSuccess(true);
//		result.setMessage("开奖成功！");
//
//		return result;
//	}
//
//}
